/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import model.Denuncia;
import org.primefaces.model.map.DefaultMapModel;
import org.primefaces.model.map.LatLng;
import org.primefaces.model.map.MapModel;
import org.primefaces.model.map.Marker;

/**
 * Document: MapBean
 * Created on: 9 juil. 2013, 18:19:11
 * @author vinicius
 */
 
@ManagedBean
public class MapBean implements Serializable {  
  
    private MapModel mapModel;
    private Denuncia denuncia;
    
    private String titulo;
    private double lat;
    private double lng;
  
    public MapBean() {  
        mapModel = new DefaultMapModel();  
        //Coordenada 
        LatLng coord1 = new LatLng(-16.603216, -49.266407);  
        //Basic marker  
        mapModel.addOverlay(new Marker(coord1, "INF-UFG"));
    }  
  
    public MapModel getMapModel() {  
        return mapModel;  
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLng() {
        return lng;
    }

    public void setLng(double lng) {
        this.lng = lng;
    }
    
    public void addMarcador(ActionEvent actionEvent) {  
        Marker marker = new Marker(new LatLng(lat, lng), titulo);  
        mapModel.addOverlay(marker);  
        addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Denúncia realizada", "Lat:" + lat + ", Lng:" + lng));  
    }
    
    public void addMessage(FacesMessage message) {  
        FacesContext.getCurrentInstance().addMessage(null, message);  
    }
    
}  
